class Solution
{
public:
    int numDifferentIntegers(string word)
    {
        int n = word.size();
        for (int i = 0; i < n; ++i)
        {
            char &c = word[i];
            if (c >= 'a' && c <= 'z')
            {
                c = ' ';
            }
            if (c == '0')
            {
                if ((i == 0 || (i > 0 && word[i - 1] == ' ')) && (i != n - 1 && (word[i + 1] >= '0' && word[i + 1] <= '9')))
                {
                    c = ' ';
                }
            }
        }
        stringstream ss(word);
        unordered_set<string> nums;
        string num;
        while (ss >> num)
        {
            nums.insert(num);
        }
        return nums.size();
    }
};